package com.zdb.datastructures.tree.redblack;

public class RedblackTree {

    private Node root = null;

    public RedblackTree() {
    }

    public void insert(int data) {
        if(root == null) {
            root = new Node(data);
        } else {
            insert(root, data);
        }
    }

    /**
     * root一定不为空
     * @param root
     * @param data
     */
    public void insert(Node root, int data) {
        // 大于root,放在右边
        if(root.data < data) {
            if(root.right == null) {
                root.right = new Node(data);
                root.right.parent = root;
            }else {
                insert(root.right, data);
            }
        } else {
            if(root.left == null) {
                root.left = new Node(data);
                root.left.parent = root;
            } else {
                insert(root.left, data);
            }
        }
    }

    /**
     * 左旋
     * @param node
     */
    public void leftRotate(Node node) {

    }

    static class Node {
        // 红黑常量
        static final int R = 1;
        static final int B = 0;

        int data;
        // 新增节点默认为红色
        int color = R;
        Node left;
        Node right;
        Node parent;

        public Node(int data) {
            this.data = data;
        }



    }


}
